home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_VB / VB_7DAYS.ZIP;1 / FINDFILE.BAS < prev    next >
Encoding:
BASIC Source File  |  1993-02-17  |  985 b   |  34 lines

  1. FINDFILEINPATH
  2.  
  3. ' This function locates a file if it's stored in a directory listed
  4. ' in the Path environment variable. It returns True (-1) if 
  5. ' successful, False (0) if the file is not found.
  6.  
  7. Function FindFileInPath% (TypePath$, FileName$)
  8.   PathValue$ = Environ$(TypePath$)
  9.   If Len(PathValue$) = 0 Then Exit Function
  10.   End If
  11.   StartPos% = 1
  12.   If Right$(PathValue$, 1) <> ";" Then 
  13.     PathValue$ = PathValue$ + ";"
  14.   End If
  15.   DelimPos% = InStr(StartPos%, PathValue$, ";")
  16.   While DelimPos%
  17.     DirValue$ = Mid$(PathValue$, StartPos%, DelimPos% - StartPos%)
  18.     If DirValue$ <> "" Then
  19.       If Right$(DirValue$, 1) <> "\" Then 
  20.         DirValue$ = DirValue$ + "\"
  21.       End If
  22.       If Dir$(DirValue$ + FileName$) <> "" Then
  23.         FileName$ = DirValue$ + FileName$
  24.         FindFileInPath% = -1
  25.         Exit Function
  26.       End If
  27.     End If
  28.     StartPos% = DelimPos% + 1
  29.     DelimPos% = InStr(StartPos%, PathValue$, ";")
  30.   Wend
  31. End Function
  32.  
  33.  
  34.